package cn.com.pc.content.domain.risk;

import cn.com.pc.content.domain.audit.Auditor;
import cn.com.pc.content.domain.content.ContentType;
import cn.com.pc.content.domain.Site;
import cn.com.pc.content.jpa.ContentTypeConverter;
import cn.com.pc.content.jpa.SiteConverter;
import lombok.Data;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 内容风险
 */
@Data
@ToString
@Entity
@Table(name = "risks")
@DynamicUpdate
@DynamicInsert
public class Risk {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private long id;

    @Column(name = "content_id")
    private String contentId;

    @Column(name = "site")
    @Convert(converter = SiteConverter.class)
    private Site site;

    @Column(name = "content_type")
    @Convert(converter = ContentTypeConverter.class)
    private ContentType contentType;

    @Column(name = "author_id")
    private long authorId;

    /**
     * 风险场景
     */
    @Column(name = "scenes")
    private RiskScenes scenes;

    /**
     * 风险系数，0-10，越高表明风险越高
     */
    @Column(name = "risk")
    private int risk;

    @OneToOne(targetEntity = Auditor.class)
    @JoinColumn(name = "auditor_id")
    private Auditor auditor;

    @Column(name = "audit_at")
    private Date auditAt;

}
